<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>mindsensors-ligthsensorarray-test3.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="preprocessor">#pragma config(Sensor, S1,     MSLSA,          sensorI2CCustomFastSkipStates9V)</span>
<span class="preprocessor"></span><span class="comment">//*!!Code automatically generated by &#39;ROBOTC&#39; configuration wizard               !!*//</span>

<span class="comment">/*</span>
<span class="comment"> * $Id: mindsensors-ligthsensorarray-test3.c 133 2013-03-10 15:15:38Z xander $</span>
<span class="comment"> */</span>
<span class="comment"></span>
<span class="comment">/**</span>
<span class="comment"> * mindsensors-lightsensorarray.h provides an API for the Mindsensors LightSensorArray Sensor.  This program</span>
<span class="comment"> * demonstrates how to use that API.</span>
<span class="comment"> *</span>
<span class="comment"> * Changelog:</span>
<span class="comment"> * - 0.1: Initial release</span>
<span class="comment"> *</span>
<span class="comment"> * Credits:</span>
<span class="comment"> * - Big thanks to Mindsensors for providing me with the hardware necessary to write and test this.</span>
<span class="comment"> *</span>
<span class="comment"> * License: You may use this code as you wish, provided you give credit where it&#39;s due.</span>
<span class="comment"> *</span>
<span class="comment"> * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. </span>
<span class="comment"></span>
<span class="comment"> * Xander Soldaat (xander_at_botbench.com)</span>
<span class="comment"> * 30 September 2012</span>
<span class="comment"> * version 0.1</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &quot;<a class="code" href="mindsensors-lightsensorarray_8h.html" title="Mindsensors LigthSensorArray.">drivers/mindsensors-lightsensorarray.h</a>&quot;</span>

<span class="keyword">const</span> <span class="keywordtype">string</span> frequencyNames[] = {<span class="stringliteral">&quot;US&quot;</span>, <span class="stringliteral">&quot;UNI&quot;</span>, <span class="stringliteral">&quot;EU&quot;</span>, };

<span class="comment">// Set the desired frequency compensation mode.  This has to do with the frequency of the</span>
<span class="comment">// AC current.  It causes flickering of the lights at the same frequency and can</span>
<span class="comment">// interfere with the sensor readings. This allows you to compensate for it.</span>
<span class="keywordtype">void</span> setFrequency(<span class="keywordtype">int</span> choice)
{
  PlaySound(soundBlip);
  <span class="keywordflow">switch</span>(choice)
  {
    <span class="keywordflow">case</span> 0: <a name="a0"></a><a class="code" href="group__msll.html#ga7f235e66c11db9a4157af510ca67d0ad">MSLSAsetUS</a>(MSLSA);  <span class="keywordflow">break</span>;
    <span class="keywordflow">case</span> 1: <a name="a1"></a><a class="code" href="group__msll.html#ga6bd6d0e08d1209ff3ae55509c6813516">MSLSAsetUni</a>(MSLSA); <span class="keywordflow">break</span>;
    <span class="keywordflow">case</span> 2: <a name="a2"></a><a class="code" href="group__msll.html#ga00ff9edf1856da054967323bf56d0610">MSLSAsetEU</a>(MSLSA);  <span class="keywordflow">break</span>;
  }
}

task main {
  <span class="keywordtype">int</span> choice = 1;

  <span class="keywordflow">while</span> (<span class="keyword">true</span>) {
    <span class="keywordflow">switch</span>(nNxtButtonPressed)
    {
      <span class="keywordflow">case</span> kEnterButton: setFrequency(choice); <span class="keywordflow">break</span>;
      <span class="keywordflow">case</span> kLeftButton:  choice = (choice == 0) ? 0 : (choice - 1); <span class="keywordflow">break</span>;
      <span class="keywordflow">case</span> kRightButton: choice = (choice == 2) ? 2 : (choice + 1); <span class="keywordflow">break</span>;
    }

    nxtDisplayCenteredTextLine(0, <span class="stringliteral">&quot;LightSensorArray&quot;</span>);
    nxtDisplayCenteredTextLine(1, <span class="stringliteral">&quot;Freq. config&quot;</span>);
    nxtDisplayCenteredBigTextLine(3, frequencyNames[choice]);
    nxtDisplayCenteredTextLine(6, <span class="stringliteral">&quot;[enter] to set&quot;</span>);
    nxtDisplayTextLine(7, <span class="stringliteral">&quot;&lt;  switch freq  &gt;&quot;</span>);

    <span class="comment">// Debounce</span>
    <span class="keywordflow">while</span> (nNxtButtonPressed != kNoButton) EndTimeSlice();
  }
}

<span class="comment">/*</span>
<span class="comment"> * $Id: mindsensors-ligthsensorarray-test3.c 133 2013-03-10 15:15:38Z xander $</span>
<span class="comment"> */</span>
</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:42 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
